package com.cirkana.viewer.profile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import com.cirkana.serial.SerializablePassData;

public class SignInPassData extends SerializablePassData {

	private Profile profile;

	public boolean hasProfile() {
		return this.profile != null;
	}
	
	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	@Override
	public void serialize(DataOutputStream out) throws IOException {
		if (this.profile == null)
			serializeBoolean(true, out);
		else {
			serializeBoolean(false, out);
			this.profile.serialize(out);
		}
	}

	@Override
	public void deserialize(DataInputStream in) throws IOException {
		this.profile = null;
		if (!deserializeBoolean(in)) {
			this.profile = new Profile();
			this.profile.deserialize(in);
		}
	}

}
